package flca.osm.perst.model;

import java.io.IOException;
import java.util.ArrayList;

import org.codehaus.jackson.map.MappingJsonFactory;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;

public class JsonArrayPNode extends ArrayList<PNode>
{
	private static final long serialVersionUID = -8683652922137439523L;

	public JsonArrayPNode(String v) throws IOException
	{
		ObjectMapper objectMapper = new ObjectMapper(new MappingJsonFactory());
		TypeReference<ArrayList<PNode>> typeRef = new TypeReference<ArrayList<PNode>>() {};
		try {
			ArrayList<PNode> list = objectMapper.readValue(v, typeRef);
			for (PNode x : list) {
				this.add((PNode) x);
			}
		} catch(IOException ex) {
			System.out.println(ex);
			throw ex;
		}
	}
}
